package org.xxpay.pay.channel.suile;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;
import org.xxpay.common.unify.AbstractPaymentConfig;

/**
 * @Package org.xxpay.pay.channel.suile
 * @Class: SuileConfig.java
 * @Description:
 * @Author leo
 * @Date 2019/6/1 0:09
 * @Version
 **/
@Component
@Data
@ToString
@NoArgsConstructor
public class SuileConfig extends AbstractPaymentConfig {

    public static final String CHANNEL_NAME = "suile";
    public static final String CHANNEL_NAME_SUILE_QR = CHANNEL_NAME + "_scanqr";

    public static final String RETURN_VALUE_SUCCESS = "000";
    public static final String RETURN_VALUE_FAIL = "-1"; //或者其他响应码
    public static final String RETURN_VALUE_HANDING = "074"; // 处理中
    public static final String RESPONSE_RESULT_SUCCESS = "success"; // 返回上游成功
    public static final String RESPONSE_RESULT_FAIL = "fail";       // 返回上游失败

    // 默认版本号
    public static final String DEFAULT_VERSION = "1.0.1";

    // 异步通知支付状态, 00 等待付款，01 付款成功，02 付款失败
    public static final String PAY_STATUS_OK = "01";


    public SuileConfig(String payParam) {
        Assert.notNull(payParam, "init sand config error");
        JSONObject object = JSON.parseObject(payParam);
        setMchId(object.getString("mchId"));
        setPrivateStorePath(object.getString("privateStorePath"));
        setPrivateStorePathPwd(object.getString("privateStorePathPwd"));
        setPublicStorePath(object.getString("publicStorePath"));
        setRequestUrl(object.getString("requestUrl"));
        // YLScanOrder:银联二维码
        setPayMode(object.getString("payMode"));
    }

}
